<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<!-- 



    
 -->

<body>
    <script>
        // var timer = setInterval(fn, 10);

        // function fn() {
        //     console.log('hello');
        // }

        //练习题：获取系统的当前日期 以下面的形式打印到控制台
        //XXXX年XX月XX日  XX时XX分XX秒
        //获取系统的当前时间
        var date = new Date();
        // 获取年月日 时分秒
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();

        var week = date.getDay();
        var hour = date.getHours();
        var minute = date.getMinutes();
        var second = date.getSeconds();


        //处理星期的格式
        switch (week) {
            case 1:
                week = '星期一';
                break;
            case 2:
                week = '星期二';
                break;
            case 3:
                week = '星期三';
                break;
            case 4:
                week = '星期四';
                break;
            case 5:
                week = '星期五';
                break;
            case 6:
                week = '星期六';
                break;
            case 0:
                week = '星期日';

        }

        //处理时分秒的格式
        if (hour < 10) {
            hour = '0' + hour;
        }
        if (minute < 10) {
            minute = '0' + minute;

        }
        if (second < 10) {
            second = '0' + second;
        }
        console.log(`${year}年${month}月${day}日${week}${hour}时${minute}分${minute}秒`);
    </script>
</body>

</html>